import { Component, OnInit } from '@angular/core';
import { NzMessageService, NzModalRef } from 'ng-zorro-antd';
import { SFSchema } from '@delon/form';
@Component({
  selector: 'business-task-edit',
  templateUrl: './edit.component.html',
})
export class BusinessTaskEditComponent implements OnInit {
  i: any = {};
  accountInfo = '新增任务';
  schema: SFSchema = {
    properties: {
      title: { type: 'string', title: '任务名称', maxLength: 50 },
      startDate: { type: 'string', title: '开始时间', format: 'date' },
      principal: {
        type: 'string',
        title: '任务负责人'
      },
      percentage: {
        type: 'string',
        title: '完成百分比'
      },
      status: {
        type: 'string',
        title: '状态',
        enum: [
          { value: 'active', label: '激活' },
          { value: 'exception', label: '停止' }
        ],
      },
      describe: {
        type: 'string',
        title: '任务描述',
        ui: {
          widget: 'textarea',
          autosize: { minRows: 2, maxRows: 6 },
        },
      }
    },
    required: ['title', 'startDate', 'principal', 'status', 'percentage'],
    ui: {
      spanLabelFixed: 120,
      grid: { span: 24 },
    },
  };
  constructor(private modal: NzModalRef, private msgSrv: NzMessageService) {}
  ngOnInit() {
    if(this.i._id) {
      this.accountInfo = '修改任务'
    }
  }
  save(value: any) {
    // this.msgSrv.success('保存成功');
    this.modal.close(value);
  }
  close() {
    this.modal.destroy();
  }
}
